import React from 'react';
import { Button,Text,View,Image,StyleSheet,Dimensions,StatusBar } from 'react-native';
import { createAppContainer,createSwitchNavigator } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
import { createBottomTabNavigator } from 'react-navigation-tabs';

const { width, height } = Dimensions.get('window')
const statusBarHeight = StatusBar.currentHeight;
import WelcomeScreen from './src/pages/Welcome/WelcomeScreen';
import Home from './src/pages/Home/Home';
import UserScreen from './src/pages/User/UserScreen';
import My from './src/pages/My/My';
import News from './src/pages/News/News';
import Lists from './src/pages/Lists/Lists';
import Documentary from './src/pages/Documentary/Documentary';
import Explain from './src/pages/Explain/Explain';
import Login from './src/pages/Login/Login';
import Site from "./src/pages/Site/Site";
import SetUserPass from "./src/pages/SetUserPass/SetUserPass";
import AuthLoading from "./src/pages/AuthLoading/AuthLoading";
import SafeContent from "./src/pages/SafeContent/SafeContent";
import UserCertification from "./src/pages/UserCertification/UserCertification";
import Userinfo from "./src/pages/Userinfo/Userinfo";
import NewsDetailed from "./src/pages/NewsDetailed/NewsDetailed";
import Live from "./src/pages/Live/Live";

import FootballGame from "./src/pages/Game/FootballGame/FootballGame";
import FootballBetList from "./src/pages/FootballBetList/FootballBetList";
import FootballBonusOpt from "./src/pages/FootballBonusOpt/FootballBonusOpt";

import BetOrder from "./src/pages/BetOrder/BetOrder";
import Follow from "./src/pages/Follow/Follow";
import Introduce from "./src/pages/Introduce/Introduce";
import FollowList from "./src/pages/FollowList/FollowList";
import FollowDetailed from "./src/pages/FollowDetailed/FollowDetailed";
import UserDetailed from "./src/pages/UserDetailed/UserDetailed";
import BetSuccess from "./src/pages/BetSuccess/BetSuccess";
import UserRank from "./src/pages/UserRank/UserRank";
import GameOrder from "./src/pages/GameOrder/GameOrder";

import FollowFx from "./src/pages/FollowFx/FollowFx";
import Guanzhu from "./src/pages/Guanzhu/Guanzhu";
import FootballLottery from "./src/pages/FootballLottery/FootballLottery";
import AccountDetails from "./src/pages/AccountDetails/AccountDetails";
import TixianPass from "./src/pages/TixianPass/TixianPass";
import Tianxian from "./src/pages/Tianxian/Tianxian";
import TXShow from "./src/pages/TXShow/TXShow";
import OrderDetail from "./src/pages/OrderDetail/OrderDetail";
import BindPhone from "./src/pages/BindPhone/BindPhone";
import UserPush from "./src/pages/UserPush/UserPush";
import ChongZhi from "./src/pages/ChongZhi/ChongZhi";
import AliPay from "./src/pages/AliPay/AliPay";
import WxPay from "./src/pages/WxPay/WxPay";
import AliSPay from "./src/pages/AliSPay/AliSPay";

import DLTGame from "./src/pages/Game/DLTGame/DLTGame";
import DLTBox from "./src/pages/Game/DLTGame/DLTBox";
import DLTBetList from "./src/pages/Game/DLTGame/DLTBetList";
import DLTLottery from "./src/pages/Game/DLTGame/DLTLottery";
import DLTNewLottery from "./src/pages/Game/DLTGame/DLTNewLottery";
import DLTOrderDetail from "./src/pages/Game/DLTGame/DLTOrderDetail";



const HomeStack = createStackNavigator({
    //ListsFlatList:{screen:ListsFlatList},
      Home: { screen: Home },
});
HomeStack.navigationOptions = ({ navigation }) => {
    var { routeName } = navigation.state.routes[navigation.state.index];
    /*
    let tabBarVisible = true;
    switch (routeName) {
        case 'Documentary':
            tabBarVisible = false;
            break;
        case 'Site':
            tabBarVisible = false;
            break;
        default:
            tabBarVisible = true;
            break;
    }
    return {
        tabBarVisible,
    };
    */
};
const ListsStack =  createStackNavigator({
    Lists: { screen: Lists },
});
const NewsStack =  createStackNavigator({
    News: { screen: News },
});
const MyStack =  createStackNavigator({
    My: { screen: My },
});
const TabNavigator= createBottomTabNavigator(
    {
        首页: { screen: HomeStack },
        开奖: { screen: ListsStack },
        资讯: { screen: NewsStack },
        我的: { screen: MyStack },
    },
    {
        defaultNavigationOptions: ({ navigation }) => ({
            tabBarIcon: ({ focused, tintColor }) => {
                const { routeName } = navigation.state;
                let iconName,iconPath;
                switch (routeName) {
                    case '首页':
                        if(focused){
                            iconPath = require('./src/image/js_img_buyshop_active.png');
                        }else{
                            iconPath = require('./src/image/js_img_buyshop.png');
                        }
                    break;
                    case '开奖':
                        if(focused){
                            iconPath = require('./src/image/js_img_announcement_active.png');
                        }else{
                            iconPath = require('./src/image/js_img_announcement.png');
                        }
                    break;
                    case '资讯':
                        if(focused){
                            iconPath = require('./src/image/js_img_consult_active.png');
                        }else{
                            iconPath = require('./src/image/js_img_consult.png');
                        }
                    break;
                    case '我的':
                        if(focused){
                            iconPath = require('./src/image/js_img_mylottery_active.png');
                        }else{
                            iconPath = require('./src/image/js_img_mylottery.png');
                        }
                    break;
                }
                return <Image style={{width:24,height:24}} source={iconPath} />;
            },
        }),
        tabBarOptions: {
            activeTintColor: 'tomato',
            inactiveTintColor: 'gray',
        },
    }
);

const RootStack = createStackNavigator({
    TabNavigator: {
        screen: TabNavigator,
        navigationOptions: {
            header: null,
        }
    },
    Login: {screen: Login},
    User: { screen: UserScreen },
    Documentary:{screen:Documentary},
    Explain:{screen:Explain},
    Site:{screen:Site},
    SetUserPass:{screen:SetUserPass},
    AuthLoading:{screen:AuthLoading},
    SafeContent:{screen:SafeContent},
    UserCertification:{screen:UserCertification},
    Userinfo:{screen:Userinfo},
   NewsDetailed:{screen:NewsDetailed},
        Live:{screen:Live},
        FootballGame:{screen:FootballGame},
    FootballBetList:{screen:FootballBetList},
    FootballBonusOpt:{screen:FootballBonusOpt},
        BetOrder:{screen:BetOrder},
        Follow:{screen:Follow},
        Introduce:{screen:Introduce},
        FollowList:{screen:FollowList},
        FollowDetailed:{screen:FollowDetailed},
    UserDetailed:{screen:UserDetailed},
    BetSuccess:{screen:BetSuccess},
    UserRank:{screen:UserRank},
    GameOrder:{screen:GameOrder},    
    FollowFx:{screen:FollowFx},
    Guanzhu:{screen:Guanzhu},
    FootballLottery:{screen:FootballLottery},
    AccountDetails:{screen:AccountDetails},
    TixianPass:{screen:TixianPass},
    Tianxian:{screen:Tianxian},
    TXShow:{screen:TXShow},
    OrderDetail:{screen:OrderDetail},
    BindPhone:{screen:BindPhone},
    UserPush:{screen:UserPush},
    ChongZhi:{screen:ChongZhi},  
    AliPay:{screen:AliPay},
    WxPay:{screen:WxPay},
    AliSPay:{screen:AliSPay},
    DLTGame:{screen:DLTGame},
    DLTBox:{screen:DLTBox},
    DLTBetList:{screen:DLTBetList},
    DLTLottery:{screen:DLTLottery},
    DLTNewLottery:{screen:DLTNewLottery},
    DLTOrderDetail:{screen:DLTOrderDetail},
},{
    /* 主屏幕的标题配置现在在这里 */
    //headerMode: 'none',
}
);

const SwitchNav = createSwitchNavigator({
    DLTBox:{screen:DLTBox},
    WelcomeScreen: WelcomeScreen,
    App: RootStack,
},{
    initialRouteName: 'WelcomeScreen',
});

export default createAppContainer(SwitchNav);
